package com.unience.ec2.eclipse.dialog;

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.SWT;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class NewAccountDialog extends org.eclipse.swt.widgets.Dialog {

	private Shell dialogShell;
	private Text textKey;
	private Label label2;
	private Button buttonCancel;
	private Canvas canvas2;
	private Button buttonAccept;
	private Canvas canvas1;
	private Text textOwnerId;
	private Label label3;
	private Text textSecret;
	private Label label1;
	private Text textName;
	private Label labelName;
	
	
	private String key;
	private String secret;
	private String ownerID;
	private String name;
	
	
	private boolean accepted = true;

	public Text getTextKey() {
		return textKey;
	}

	public Text getTextOwnerId() {
		return textOwnerId;
	}

	public Text getTextSecret() {
		return textSecret;
	}

	public Text getTextName() {
		return textName;
	}

	public boolean isAccepted() {
		return accepted;
	}

	/**
	* Auto-generated main method to display this 
	* org.eclipse.swt.widgets.Dialog inside a new Shell.
	*/
	public static void main(String[] args) {
		try {
			Display display = Display.getDefault();
			Shell shell = new Shell(display);
			NewAccountDialog inst = new NewAccountDialog(shell, SWT.NULL);
			inst.open();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public NewAccountDialog(Shell parent, int style) {
		super(parent, style);
	}

	public void open() {
		try {
			Shell parent = getParent();
			dialogShell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);

			FormLayout dialogShellLayout = new FormLayout();
			dialogShell.setLayout(dialogShellLayout);
			dialogShell.layout();
			dialogShell.pack();			
			dialogShell.setSize(501, 197);
			dialogShell.setText("Add Ec2 Account");
			{
				labelName = new Label(dialogShell, SWT.NONE);
				FormData labelNameLData = new FormData();
				labelNameLData.width = 61;
				labelNameLData.height = 17;
				labelNameLData.left =  new FormAttachment(10, 1000, 0);
				labelNameLData.right =  new FormAttachment(132, 1000, 0);
				labelNameLData.top =  new FormAttachment(36, 1000, 0);
				labelNameLData.bottom =  new FormAttachment(120, 1000, 0);
				labelName.setLayoutData(labelNameLData);
				labelName.setText("Name");
			}
			{
				FormData textNameLData = new FormData();
				textNameLData.width = 373;
				textNameLData.height = 17;
				textNameLData.left =  new FormAttachment(194, 1000, 0);
				textNameLData.right =  new FormAttachment(947, 1000, 0);
				textNameLData.top =  new FormAttachment(27, 1000, 0);
				textNameLData.bottom =  new FormAttachment(130, 1000, 0);
				textName = new Text(dialogShell, SWT.NONE);
				textName.setLayoutData(textNameLData);
			}
			{
				label1 = new Label(dialogShell, SWT.NONE);
				FormData label1LData = new FormData();
				label1LData.width = 90;
				label1LData.height = 17;
				label1LData.left =  new FormAttachment(10, 1000, 0);
				label1LData.right =  new FormAttachment(190, 1000, 0);
				label1LData.top =  new FormAttachment(165, 1000, 0);
				label1LData.bottom =  new FormAttachment(248, 1000, 0);
				label1.setLayoutData(label1LData);
				label1.setText("Key");
			}
			{
				textKey = new Text(dialogShell, SWT.NONE);
				FormData textKeyLData = new FormData();
				textKeyLData.width = 375;
				textKeyLData.height = 17;
				textKeyLData.left =  new FormAttachment(194, 1000, 0);
				textKeyLData.right =  new FormAttachment(951, 1000, 0);
				textKeyLData.top =  new FormAttachment(155, 1000, 0);
				textKeyLData.bottom =  new FormAttachment(258, 1000, 0);
				textKey.setLayoutData(textKeyLData);
			}
			{
				label2 = new Label(dialogShell, SWT.NONE);
				FormData label2LData = new FormData();
				label2LData.width = 90;
				label2LData.height = 17;
				label2LData.left =  new FormAttachment(10, 1000, 0);
				label2LData.right =  new FormAttachment(190, 1000, 0);
				label2LData.top =  new FormAttachment(293, 1000, 0);
				label2LData.bottom =  new FormAttachment(376, 1000, 0);
				label2.setLayoutData(label2LData);
				label2.setText("Secret");
			}
			{
				FormData textSecretLData = new FormData();
				textSecretLData.width = 374;
				textSecretLData.height = 17;
				textSecretLData.left =  new FormAttachment(194, 1000, 0);
				textSecretLData.right =  new FormAttachment(949, 1000, 0);
				textSecretLData.top =  new FormAttachment(283, 1000, 0);
				textSecretLData.bottom =  new FormAttachment(386, 1000, 0);
				textSecret = new Text(dialogShell, SWT.NONE);
				textSecret.setLayoutData(textSecretLData);
			}
			{
				label3 = new Label(dialogShell, SWT.NONE);
				FormData label3LData = new FormData();
				label3LData.width = 83;
				label3LData.height = 17;
				label3LData.left =  new FormAttachment(10, 1000, 0);
				label3LData.right =  new FormAttachment(176, 1000, 0);
				label3LData.top =  new FormAttachment(421, 1000, 0);
				label3LData.bottom =  new FormAttachment(504, 1000, 0);
				label3.setLayoutData(label3LData);
				label3.setText("OwnerId");
			}
			{
				FormData textOwnerIdLData = new FormData();
				textOwnerIdLData.width = 370;
				textOwnerIdLData.height = 17;
				textOwnerIdLData.left =  new FormAttachment(194, 1000, 0);
				textOwnerIdLData.right =  new FormAttachment(941, 1000, 0);
				textOwnerIdLData.top =  new FormAttachment(411, 1000, 0);
				textOwnerIdLData.bottom =  new FormAttachment(514, 1000, 0);
				textOwnerId = new Text(dialogShell, SWT.NONE);
				textOwnerId.setLayoutData(textOwnerIdLData);
			}
			{
				FormData canvas1LData = new FormData();
				canvas1LData.width = 64;
				canvas1LData.height = 20;
				canvas1LData.left =  new FormAttachment(10, 1000, 0);
				canvas1LData.right =  new FormAttachment(138, 1000, 0);
				canvas1LData.top =  new FormAttachment(559, 1000, 0);
				canvas1LData.bottom =  new FormAttachment(657, 1000, 0);
				canvas1 = new Canvas(dialogShell, SWT.NONE);
				canvas1.setLayoutData(canvas1LData);
			}
			{
				buttonAccept = new Button(dialogShell, SWT.PUSH | SWT.CENTER);
				FormData buttonAcceptLData = new FormData();
				buttonAcceptLData.width = 56;
				buttonAcceptLData.height = 29;
				buttonAcceptLData.left =  new FormAttachment(703, 1000, 0);
				buttonAcceptLData.right =  new FormAttachment(815, 1000, 0);
				buttonAcceptLData.top =  new FormAttachment(539, 1000, 0);
				buttonAcceptLData.bottom =  new FormAttachment(682, 1000, 0);
				buttonAccept.setLayoutData(buttonAcceptLData);
				buttonAccept.setText("Accept");
				buttonAccept.addSelectionListener(new SelectionAdapter() {
					public void widgetSelected(SelectionEvent event) {		
						
						key = getTextKey().getText();
						name = getTextName().getText();
						secret = getTextSecret().getText();
						ownerID = getTextOwnerId().getText();
						dialogShell.close();
					}
				});
			}
			{
				FormData canvas2LData = new FormData();
				canvas2LData.width = 64;
				canvas2LData.height = 20;
				canvas2LData.left =  new FormAttachment(10, 1000, 0);
				canvas2LData.right =  new FormAttachment(138, 1000, 0);
				canvas2LData.top =  new FormAttachment(726, 1000, 0);
				canvas2LData.bottom =  new FormAttachment(825, 1000, 0);
				canvas2 = new Canvas(dialogShell, SWT.NONE);
				canvas2.setLayoutData(canvas2LData);
			}
			{
				buttonCancel = new Button(dialogShell, SWT.PUSH | SWT.CENTER);
				FormData buttonCancelLData = new FormData();
				buttonCancelLData.width = 55;
				buttonCancelLData.height = 32;
				buttonCancelLData.left =  new FormAttachment(839, 1000, 0);
				buttonCancelLData.right =  new FormAttachment(949, 1000, 0);
				buttonCancelLData.top =  new FormAttachment(539, 1000, 0);
				buttonCancelLData.bottom =  new FormAttachment(697, 1000, 0);
				buttonCancel.setLayoutData(buttonCancelLData);
				buttonCancel.setText("Cancel");
				buttonCancel.addSelectionListener(new SelectionAdapter() {
					public void widgetSelected(SelectionEvent event) {			
						accepted = false;
						dialogShell.close();
					}
				});
			}
			dialogShell.setLocation(getParent().toDisplay(100, 100));
			dialogShell.open();
			Display display = dialogShell.getDisplay();
			while (!dialogShell.isDisposed()) {
				if (!display.readAndDispatch())
					display.sleep();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public String getSecret() {
		return secret;
	}

	public void setSecret(String secret) {
		this.secret = secret;
	}

	public String getOwnerID() {
		return ownerID;
	}

	public void setOwnerID(String ownerID) {
		this.ownerID = ownerID;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
}
